//
//  XYTOrderListCell.m
//  XYTPayOrderSystem
//
//  Created by wupeng on 2017/8/24.
//  Copyright © 2017年 wupeng. All rights reserved.
//

#import "XYTOrderListCell.h"

@interface XYTOrderListCell ()

@end

@implementation XYTOrderListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    self.backgroundColor = [UIColor clearColor];
    
    UIView *topLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, boundsWidth, 1)];
    topLine.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:topLine];
    self.topLine = topLine;
    
    XYTOrderListView *mainView = [[XYTOrderListView alloc] initWithFrame:CGRectMake(0, 1, mainView_Width, boundsHeight-1)];
    mainView.delegate = self;
    mainView.separateColor = [UIColor lightGrayColor];
    mainView.orderSumLab.textColor = [UIColor redColor];
    mainView.statusLab.textColor = [UIColor greenColor];
    [mainView.detailBtn setImage:[UIImage imageNamed:@"detail_2"] forState:UIControlStateNormal];
    [mainView.detailBtn setContentMode:UIViewContentModeScaleAspectFill];
    [self.contentView addSubview:mainView];
    self.mainView = mainView;
    
    UIView *bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0, boundsHeight-1, boundsWidth, 1)];
    bottomLine.backgroundColor = [UIColor lightGrayColor];
    bottomLine.hidden = YES;
    [self.contentView addSubview:bottomLine];
    self.bottomLine = bottomLine;
    
}

- (void)onClickShowDetail{
    if (self.delegate && [self.delegate respondsToSelector:@selector(onClickDetail:)]) {
        [self.delegate onClickDetail:self.orderModel];
    }
}

-(void)setOrderModel:(XYTOrderModel *)orderModel{
    _orderModel = orderModel;
    self.mainView.telNumLab.text = _orderModel.phone;
    self.mainView.orderSumLab.text = FloatToStr(_orderModel.moneyTotal);
    self.mainView.statusLab.text = [self transferStatus:_orderModel.status];
    self.mainView.timeLab.text = _orderModel.createDate;
}

- (NSString *)transferStatus:(NSInteger)status{
    NSString *statusStr = @"";
    switch (status) {
        case 0:
            statusStr = @"已提交";
            break;
        case 1:
            statusStr = @"成功";
            break;
        case 2:
            statusStr = @"过期";
            break;
        case 3:
            statusStr = @"不存在";
            break;
        case 4:
            statusStr = @"待付款";
            break;
            
        default:
            break;
    }
    return statusStr;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
